package sg.edu.nus.iss.billing.controller;

import java.util.ArrayList;
import java.util.List;

import sg.edu.nus.iss.billing.common.exception.BadDaoCallException;
import sg.edu.nus.iss.billing.dummyData.CustomerDummy;
import sg.edu.nus.iss.billing.exception.customer.InvalidCustomerDataException;
import sg.edu.nus.iss.billing.service.customer.CustomerServiceImpl;
import sg.edu.nus.iss.billing.service.login.LoginMemberServiceImpl;
import sg.edu.nus.iss.billing.vo.customer.CustomerVO;
import sg.edu.nus.iss.billing.vo.login.LoginVO;

public class BillManagementController {
	
	/*
	 * login part
	 * validLogin => can get loginMemberId, userRole from swing side.
	 * invalid => can check userId  password, 
	 */
	private LoginMemberServiceImpl lmemberServiceImpl;
	public LoginVO checkLoginMember(String memberId, String password){
		
		LoginVO lvo = new LoginVO(memberId, password);
		lvo = lmemberServiceImpl.findLoginMemberInfo(memberId, password);
		if(lvo!=null || !(lvo.getUserRole().equalsIgnoreCase("ACTV"))){
			lvo.setUserID("");
			lvo.setPassword("");
		}
		return lvo;
	}
	
	/*
	 * CustomerPart
	 */
	List<CustomerVO> customerList;
	CustomerServiceImpl serviceImpl = new CustomerServiceImpl();
	CustomerDummy cDummy;
	
	
	public BillManagementController(){
		customerList = new ArrayList<CustomerVO>();
		cDummy = new CustomerDummy();
	}
	
	public String registerCustomer() throws InvalidCustomerDataException, BadDaoCallException{
		CustomerVO customerVO = cDummy.getCustomer();
		String accNo = serviceImpl.registerCustomer(customerVO);
		return accNo;
	}
}
